package cn.stylefeng.guns.modular.base.item.controller;

import cn.stylefeng.guns.modular.base.item.entity.ItemClass;
import cn.stylefeng.guns.modular.base.item.pojo.request.ItemClassRequest;
import cn.stylefeng.guns.modular.base.item.service.ItemClassService;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 基础数据-存货分类控制器
 *
 * @author caoxf
 * @since 2023/11/20 22:56
 */
    @RestController
    @ApiResource(name = "基础数据-存货分类")
    public class ItemClassController {

    @Resource
    private ItemClassService itemclassService;

    /**
     * 添加基础数据-存货分类
     *
     * @author caoxf
     * @since 2023/11/20 22:56
     */
    @PostResource(name = "添加基础数据-存货分类", path = "/itemclass/add")
    public ResponseData<ItemClass> add(@RequestBody @Validated(ItemClassRequest.add.class) ItemClassRequest itemclassRequest) {
        itemclassService.add(itemclassRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 删除基础数据-存货分类
     *
     * @author caoxf
     * @since 2023/11/20 22:56
     */
    @PostResource(name = "删除基础数据-存货分类", path = "/itemclass/delete")
    public ResponseData<?> delete(@RequestBody @Validated(ItemClassRequest.delete.class) ItemClassRequest itemclassRequest) {
        itemclassService.del(itemclassRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 批量删除基础数据-存货分类
     *
     * @author caoxf
     * @since 2023/11/20 22:56
     */
    @PostResource(name = "批量删除基础数据-存货分类", path = "/itemclass/batchDelete")
    public ResponseData<?> batchDelete(@RequestBody @Validated(BaseRequest.batchDelete.class) ItemClassRequest itemclassRequest) {
        itemclassService.batchDelete(itemclassRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 编辑基础数据-存货分类
     *
     * @author caoxf
     * @since 2023/11/20 22:56
     */
    @PostResource(name = "编辑基础数据-存货分类", path = "/itemclass/edit")
    public ResponseData<?> edit(@RequestBody @Validated(ItemClassRequest.edit.class) ItemClassRequest itemclassRequest) {
        itemclassService.edit(itemclassRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 查看基础数据-存货分类详情
     *
     * @author caoxf
     * @since 2023/11/20 22:56
     */
    @GetResource(name = "查看基础数据-存货分类详情", path = "/itemclass/detail")
    public ResponseData<ItemClass> detail(@Validated(ItemClassRequest.detail.class) ItemClassRequest itemclassRequest) {
        return new SuccessResponseData<>(itemclassService.detail(itemclassRequest));
    }

    /**
     * 获取基础数据-存货分类列表
     *
     * @author caoxf
     * @since 2023/11/20 22:56
     */
    @GetResource(name = "获取基础数据-存货分类列表", path = "/itemclass/list")
    public ResponseData<List<ItemClass>> list(ItemClassRequest itemclassRequest) {
        return new SuccessResponseData<>(itemclassService.findList(itemclassRequest));
    }

    /**
     * 获取基础数据-存货分类列表（带分页）
     *
     * @author caoxf
     * @since 2023/11/20 22:56
     */
    @GetResource(name = "获取基础数据-存货分类列表（带分页）", path = "/itemclass/page")
    public ResponseData<PageResult<ItemClass>> page(ItemClassRequest itemclassRequest) {
        return new SuccessResponseData<>(itemclassService.findPage(itemclassRequest));
    }

}
